﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Meqs.Entity;
using Meqs.Logic.Interface;

public partial class Credit_Teacher_Reprots_SelectStudent : ContainerBasePage
{
    protected static String getText
    {
        get
        {
            String code;
            code = HttpContext.Current.Request["text"];
            return code;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (getText != null)
            {
                txtText.Text = HttpUtility.UrlDecode(getText);
                btnQuery_Click(null,null);
            }
        }
    }

    /// <summary>
    /// 查询按钮事件
    /// </summary>
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        IList<StudentInfo> list = Container<IStudentInfoLogic>.Instance.FindStudentByCodeAndName(SchoolMark, txtText.Text);

        CreateTable(list);
    }

    /// <summary>
    /// 构造表格
    /// </summary>
    private void CreateTable(IList<StudentInfo> list)
    {
        int width = 0;
        #region 构造表头
        TableHeaderRow hrow = new TableHeaderRow();
        TableHeaderCell hcell = new TableHeaderCell();
        hcell.Text = "学号";
        hcell.Style[HtmlTextWriterStyle.Width] = "70px";
        width += 70;
        hrow.Cells.Add(hcell);

        hcell = new TableHeaderCell();
        hcell.Text = "姓名";
        hcell.Style[HtmlTextWriterStyle.Width] = "70px";
        width += 70;
        hrow.Cells.Add(hcell);

        hcell = new TableHeaderCell();
        hcell.Text = "学生成长档案";
        hcell.Style[HtmlTextWriterStyle.Width] = "140px";
        width += 140;
        hrow.Cells.Add(hcell);

        tbResult.Rows.Add(hrow);
        tbResult.Style[HtmlTextWriterStyle.Width] = String.Format("{0}px", width);
        #endregion

        #region 填充内容
        TableRow row;
        TableCell cell;
        if(list == null || list.Count < 1)
            return;

        foreach (StudentInfo info in list)
        {
            row = new TableRow();
            cell = new TableCell();
            cell.Text = info.StudentCode;
            row.Cells.Add(cell);

            cell = new TableCell();
            cell.Text = info.StudentName;
            row.Cells.Add(cell);

            cell = new TableCell();
            HyperLink control = new HyperLink();
            control.Text = "查看";
            control.NavigateUrl = String.Format("../Reprots/StudentEvalHistory.aspx?id={0}&code={1}&name={2}&show=1&url=2&text=" + HttpUtility.UrlEncode(txtText.Text)+"&end=0", info.RID, info.StudentCode, HttpUtility.UrlEncode(info.StudentName));
            cell.Controls.Add(control);
            row.Cells.Add(cell);
            tbResult.Rows.Add(row);
        }
        #endregion
    }
}
